package com.atguigu.yygh.user.controller.admin;

import com.atguigu.yygh.common.result.R;
import com.atguigu.yygh.model.user.UserInfo;
import com.atguigu.yygh.user.service.UserInfoService;
import com.atguigu.yygh.vo.user.UserInfoQueryVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author:hx
 * @DateTime:2022/11/15 18:37
 * @Description:
 */
@RestController
@RequestMapping("/user/admin/userInfo/")
public class AdminUserInfoController {

    @Autowired
    private UserInfoService userInfoService;

    @PostMapping("/{page}/{limit}")
    public R getPageList(@PathVariable Integer page, @PathVariable Integer limit, @RequestBody UserInfoQueryVo userInfoQueryVo){
        IPage<UserInfo> pageModel = userInfoService.getPageList(page,limit,userInfoQueryVo);
        return R.ok().data("pageModel",pageModel);
    }

    @GetMapping("/lock/{id}/{status}")
    public R lock(@PathVariable Long id,@PathVariable Integer status){
        userInfoService.lock(id,status);
        return R.ok();
    }

    @GetMapping("/show/{id}")
    public R show(@PathVariable Long id){
        Map<String,Object> map = userInfoService.show(id);
        return R.ok().data(map);
    }

    @GetMapping("/approval/{id}/{authStatus}")
    public R approval(@PathVariable Long id,@PathVariable Integer authStatus){
        userInfoService.approval(id,authStatus);
        return R.ok();
    }
}
